<?php
/**
 * RUBIK IT Solution & Development ltd.
 *
 * PROJECT		: Rubik Ultimate
 * @version 	: 1.1
 * COPYRIGHT	: 2008
 * ------------------------------------------------------
 * 
 * [GENERAL INFO OF THIS FILE] 
 *
 * @author			hoadn <hoadn@rubik.com.vn>
 * @package		 	core.html.filedInfo
 *
 * Created on	:Sep 19, 2008
 */

// no direct access
defined ( '_FW_EXEC' ) or die ( 'Restricted access' );

RCoreImporter::cls('html.fieldInfo.BasicFileHtmlFieldInfo');

class SqlFileHtmlFieldInfo extends FlashFileHtmlFieldInfo {
	
	var $_sql = "";
	var $_fieldname = "";	
	/**
	 * Constructor
	 *
	 * @param string $basicName
	 */
	function __construct($basicName, $linkRule = null, $sql, $fieldname) {
		$this->_sql = "SELECT ".$fieldname." FROM ".$sql;	
		$this->_fieldname = $fieldname;
		parent::__construct($basicName, $linkRule);		
	}
	
	/**
	 * Function for geting the html for previewing data
	 *
	 * @return string
	 */
	function buildHtmlPreviewData($extAttributes = '', $key=null, $dataType ='S') {		
		$sql = $this->_sql.$key;		 		
		$object = SysDatabase::loadObject($sql);
		eval ("\$link = \$object->".$this->_fieldname.";");			
	
		$width1 = $this->_thumbSize['width'];
		$height = $this->_thumbSize['height'];
		$html = RHtmlHelper::createFlashObject($link, $width1, $height);

		$css = "
		.flash_preview div.view {
			left: {$width1}px;
		}
		";
		SysResponse::addStyleSheetContent($css);
		
		
		$width = $this->_largeSize['width'];
		$height = $this->_largeSize['height'];			
		
		$html1 = RHtmlHelper::createFlashObject($link, $width, $height);
		
		$html = '<div class="flash_preview" style="width: '.$width1.'px;"><div class="preview">'.$html.'</div><div class="view">'.$html1.'</div></div>';
		return $html;
	}		
	
}
?>